<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Prof.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="System.Linq"%>
<%@ Import Namespace="CDIO1.Models"%>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        lbSID.Text = "" + ViewData["syllabusID"];
        scheduleID.Text = "" + ViewData["scheduleID"];
        lbLanguge.Text = "viet";

        if (Int32.Parse(scheduleID.Text) == -1)
        {
            return;
        }
        if (!IsPostBack)
        {
            DataView dv1 = (DataView)TeachMethodSyllabusDataSource.Select(DataSourceSelectArguments.Empty);
            for (int i = 0; i < dv1.Table.Rows.Count; i++)
            {
                (gvTeachingMethod.Rows[(int)dv1.Table.Rows[i][0] - 1].FindControl("cbTeachMethod") as CheckBox).Checked = true;
                (gvTeachingMethod.Rows[(int)dv1.Table.Rows[i][0] - 1].FindControl("txtDescription") as TextBox).Text = (string)dv1.Table.Rows[i][1];
            }

            DataView dv2 = (DataView)EvalMethodSyllabusDataSource.Select(DataSourceSelectArguments.Empty);
            for (int i = 0; i < dv2.Table.Rows.Count; i++)
            {
                (gvEvaluateMethod.Rows[(int)dv2.Table.Rows[i][0] - 1].FindControl("cbMethod") as CheckBox).Checked = true;
                (gvEvaluateMethod.Rows[(int)dv2.Table.Rows[i][0] - 1].FindControl("txtPercent") as TextBox).Text = "" + dv2.Table.Rows[i][1];
                (gvEvaluateMethod.Rows[(int)dv2.Table.Rows[i][0] - 1].FindControl("txtLO") as TextBox).Text = (string)dv2.Table.Rows[i][2];
            }
            
        }
        //lbSID.Text = Session["languge"] + "";
        
    }


    protected void gvPractice_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        string str = "";
        if (((Label)e.Row.Controls[0].FindControl("lbNumber")) != null)
        {
            int t = e.Row.RowIndex + 1;
            ((Label)e.Row.Controls[0].FindControl("lbNumber")).Text = "" + t + ". ";
        }
    }

    protected void btnInsertPractice_Click(object sender, EventArgs e)
    {
        int syllabusID = Convert.ToInt32(lbSID.Text);
        int scheID = Convert.ToInt32(scheduleID.Text);
        var db = new CourseScheduleDataContext();
        Practice p = new Practice();
        p.CourseScheduleID = scheID;
        p.Chapter = ((TextBox)gvPractice.FooterRow.FindControl("txtChapter")).Text;
        p.WorkingHour = Convert.ToInt32(((TextBox)gvPractice.FooterRow.FindControl("txtHour")).Text);
        p.Resources = ((TextBox)gvPractice.FooterRow.FindControl("txtRes")).Text;
        p.Duration = ((TextBox)gvPractice.FooterRow.FindControl("txtWeek")).Text;
        p.Status = 1;
        p.Name = ((TextBox)gvPractice.FooterRow.FindControl("txtTopic")).Text;
        p.LectureLab = ((CheckBox)gvPractice.FooterRow.FindControl("cbox1")).Checked;
        p.LabPractice = ((CheckBox)gvPractice.FooterRow.FindControl("cbox2")).Checked;
        p.HomePractice = ((CheckBox)gvPractice.FooterRow.FindControl("cbox3")).Checked;

        db.Practices.InsertOnSubmit(p);
        db.SubmitChanges();
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void gvProject_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        string str = "";
        if (((Label)e.Row.Controls[0].FindControl("lbNumber")) != null)
        {
            int t = e.Row.RowIndex + 1;
            ((Label)e.Row.Controls[0].FindControl("lbNumber")).Text = "" + t + ". ";
        }
    }

    protected void btnInsertProject_Click(object sender, EventArgs e)
    {
        int syllabusID = Convert.ToInt32(lbSID.Text);
        int scheID = Convert.ToInt32(scheduleID.Text);
        var db = new CourseScheduleDataContext();
        Project p = new Project();
        p.CourseScheduleID = scheID;
        p.Chapter = ((TextBox)gvProject.FooterRow.FindControl("txtChapter")).Text;
        p.WorkingHour = Convert.ToInt32(((TextBox)gvProject.FooterRow.FindControl("txtHour")).Text);
        p.Resources = ((TextBox)gvProject.FooterRow.FindControl("txtRes")).Text;
        p.Duration = ((TextBox)gvProject.FooterRow.FindControl("txtWeek")).Text;
        p.Status = 1;
        p.Name = ((TextBox)gvProject.FooterRow.FindControl("txtTopic")).Text;
        p.Presentation = ((CheckBox)gvProject.FooterRow.FindControl("cbox1")).Checked;
        p.RealProject = ((CheckBox)gvProject.FooterRow.FindControl("cbox2")).Checked;
        
        db.Projects.InsertOnSubmit(p);
        db.SubmitChanges();
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void gvLecture_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        string str = "";
        if (((Label)e.Row.Controls[0].FindControl("lbNumber")) != null)
        {
            int t = e.Row.RowIndex + 1;
            ((Label)e.Row.Controls[0].FindControl("lbNumber")).Text = "" + t + ". ";
        }
    }

    protected void gvLecture_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int lectureID = Convert.ToInt32(((Label)gvLecture.Rows[e.RowIndex].FindControl("lbID")).Text);
        int teachMethodID = Convert.ToInt32(((DropDownList)gvLecture.Rows[e.RowIndex].FindControl("dlTeachMethod")).SelectedValue);
        int evalMethodID = Convert.ToInt32(((DropDownList)gvLecture.Rows[e.RowIndex].FindControl("dlEvalMethod")).SelectedValue);

        var db = new CourseScheduleDataContext();
        TheoryLecture l = db.TheoryLectures.Single(p => p.ID == lectureID);
        l.EvalMethodID = evalMethodID;
        l.TeachingMethodID = teachMethodID;
        l.Title = ((TextBox)gvLecture.Rows[e.RowIndex].FindControl("txtTitle")).Text;
        l.TopicDescription = ((TextBox)gvLecture.Rows[e.RowIndex].FindControl("txtDes")).Text;
        l.ReferenceData = ((TextBox)gvLecture.Rows[e.RowIndex].FindControl("txtRef")).Text;
        l.Chapter = ((TextBox)gvLecture.Rows[e.RowIndex].FindControl("txtChapter")).Text;
        l.Duration = ((TextBox)gvLecture.Rows[e.RowIndex].FindControl("txtDuration")).Text;
        l.Topic = ((CheckBox)gvLecture.Rows[e.RowIndex].FindControl("cbox1")).Checked;
        l.Reference = ((CheckBox)gvLecture.Rows[e.RowIndex].FindControl("cbox2")).Checked;

        db.SubmitChanges();
        gvLecture.EditIndex = -1;

        int syllabusID = Convert.ToInt32(lbSID.Text);
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);      
    }

    protected void btnInsertLecture_Click(object sender, EventArgs e)
    {
        int teachMethodID = Convert.ToInt32(((DropDownList)gvLecture.FooterRow.FindControl("dlTeachMethod")).SelectedValue);
        int evalMethodID = Convert.ToInt32(((DropDownList)gvLecture.FooterRow.FindControl("dlEvalMethod")).SelectedValue);
        int scheduleID = Convert.ToInt32(lbSID.Text);
        
        var db = new CourseScheduleDataContext();
        TheoryLecture l = new TheoryLecture();
        l.EvalMethodID = evalMethodID;
        l.TeachingMethodID = teachMethodID;
        l.Title = ((TextBox)gvLecture.FooterRow.FindControl("txtTitle")).Text;
        l.TopicDescription = ((TextBox)gvLecture.FooterRow.FindControl("txtDes")).Text;
        l.ReferenceData = ((TextBox)gvLecture.FooterRow.FindControl("txtRef")).Text;
        l.Chapter = ((TextBox)gvLecture.FooterRow.FindControl("txtChapter")).Text;
        l.Duration = ((TextBox)gvLecture.FooterRow.FindControl("txtDuration")).Text;
        l.Topic = ((CheckBox)gvLecture.FooterRow.FindControl("cbox1")).Checked;
        l.Reference = ((CheckBox)gvLecture.FooterRow.FindControl("cbox2")).Checked;
        l.CourseScheduleID = scheduleID;
        l.Status = 1;

        db.TheoryLectures.InsertOnSubmit(l);
        db.SubmitChanges();

        int syllabusID = Convert.ToInt32(lbSID.Text);
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void gvLecture_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int lectureID = Convert.ToInt32(((Label)gvLecture.Rows[e.RowIndex].FindControl("lbID")).Text);
        var db = new CourseScheduleDataContext();
        TheoryLecture l = db.TheoryLectures.Single(p => p.ID == lectureID);

        db.TheoryLectures.DeleteOnSubmit(l);
        db.SubmitChanges();

        int syllabusID = Convert.ToInt32(lbSID.Text);
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void dvFormula_ItemInserting(object sender, DetailsViewInsertEventArgs e)
    {
        string formula = ((TextBox)dvFormula.FindControl("txtFormula")).Text;
        int syllabusID = Convert.ToInt32(lbSID.Text);
        var db = new SyllabusDataContext();
        GradeFormula g = new GradeFormula();
        g.SyllabusID = syllabusID;
        g.Status = 1;
        g.Formula = formula;
        db.GradeFormulas.InsertOnSubmit(g);
        db.SubmitChanges();

        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void dvFormula_ItemDeleting(object sender, DetailsViewDeleteEventArgs e)
    {
        int formulaID = Convert.ToInt32(((Label)dvFormula.FindControl("lbID")).Text);
        var db = new SyllabusDataContext();
        GradeFormula g = db.GradeFormulas.Single(p => p.ID == formulaID);
        db.GradeFormulas.DeleteOnSubmit(g);
        db.SubmitChanges();

        int syllabusID = Convert.ToInt32(lbSID.Text);
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void lnkUpdate_Click(object sender, EventArgs e)
    {
        int methodID;
        int scheID = Convert.ToInt32("" + ViewData["scheduleID"]);
        int sID = Convert.ToInt32("" + ViewData["syllabusID"]);
        var db = new CourseScheduleDataContext();
        var syllabusDb = new SyllabusDataContext();        
        
        for (int i = 0; i < gvTeachingMethod.Rows.Count; i++)
        {
            methodID = Convert.ToInt32((gvTeachingMethod.Rows[i].FindControl("lbID") as Label).Text);
            if ((gvTeachingMethod.Rows[i].FindControl("cbTeachMethod") as CheckBox).Checked == false)
            {               
                var lectures = from p in db.TheoryLectures
                               where p.CourseScheduleID == scheID && p.TeachingMethodID == methodID
                               select p;
                db.TheoryLectures.DeleteAllOnSubmit(lectures);
                db.SubmitChanges();

                TeachMethodSyllabusDataSource.DeleteParameters[1].DefaultValue = ""+methodID;
                TeachMethodSyllabusDataSource.DeleteParameters[0].DefaultValue = lbSID.Text;
                TeachMethodSyllabusDataSource.Delete();
            }
            else
            {
                var methods = from p in syllabusDb.TeachMethodSyllabus
                              where p.TeachingMethodID == methodID && p.SyllabusID == sID
                              select p;
                if (methods.Count() > 0) //update
                {
                    TeachMethodSyllabusDataSource.UpdateParameters[0].DefaultValue =
                                (gvTeachingMethod.Rows[i].FindControl("txtDescription") as TextBox).Text;
                    TeachMethodSyllabusDataSource.UpdateParameters[1].DefaultValue = lbSID.Text;
                    TeachMethodSyllabusDataSource.UpdateParameters[2].DefaultValue = "" + methodID;
                    TeachMethodSyllabusDataSource.Update();
                }
                else
                {
                    TeachMethodSyllabusDataSource.InsertParameters[0].DefaultValue = lbSID.Text;
                    TeachMethodSyllabusDataSource.InsertParameters[1].DefaultValue = "" + methodID;
                    TeachMethodSyllabusDataSource.InsertParameters[2].DefaultValue =
                        (gvTeachingMethod.Rows[i].FindControl("txtDescription") as TextBox).Text;
                    TeachMethodSyllabusDataSource.Insert();                 
                }
            }
        }
        Response.Redirect("/Admin/ManageSyllabus/" + sID);
    }

    protected void lnUpdateEvalMethod_Click(object sender, EventArgs e)
    {
        int methodID;
        int scheID = Convert.ToInt32("" + ViewData["scheduleID"]);
        int sID = Convert.ToInt32("" + ViewData["syllabusID"]);
        var db = new CourseScheduleDataContext();
        var syllabusDb = new SyllabusDataContext();

        for (int i = 0; i < gvEvaluateMethod.Rows.Count; i++)
        {
            methodID = Convert.ToInt32((gvTeachingMethod.Rows[i].FindControl("lbID") as Label).Text);
            if ((gvEvaluateMethod.Rows[i].FindControl("cbMethod") as CheckBox).Checked == false)
            {
                var lectures = from p in db.TheoryLectures
                               where p.CourseScheduleID == scheID && p.EvalMethodID == methodID
                               select p;
                db.TheoryLectures.DeleteAllOnSubmit(lectures);
                db.SubmitChanges();

                EvalMethodSyllabusDataSource.DeleteParameters[1].DefaultValue = "" + methodID;
                EvalMethodSyllabusDataSource.DeleteParameters[0].DefaultValue = lbSID.Text;
                EvalMethodSyllabusDataSource.Delete();
            }
            else
            {
                var methods = from p in syllabusDb.EvalMethodSyllabus
                              where p.EvalMethodID == methodID && p.SyllabusID == sID
                              select p;
                if (methods.Count() > 0)
                {
                    EvalMethodSyllabusDataSource.UpdateParameters[0].DefaultValue =
                                (gvEvaluateMethod.Rows[i].FindControl("txtPercent") as TextBox).Text;
                    EvalMethodSyllabusDataSource.UpdateParameters[1].DefaultValue =
                                (gvEvaluateMethod.Rows[i].FindControl("txtLO") as TextBox).Text;
                    EvalMethodSyllabusDataSource.UpdateParameters[2].DefaultValue = lbSID.Text;
                    EvalMethodSyllabusDataSource.UpdateParameters[3].DefaultValue = "" + methodID;
                    EvalMethodSyllabusDataSource.Update();
                }
                else
                {
                    EvalMethodSyllabusDataSource.InsertParameters[0].DefaultValue = lbSID.Text;
                    EvalMethodSyllabusDataSource.InsertParameters[1].DefaultValue = "" + methodID;
                    EvalMethodSyllabusDataSource.InsertParameters[2].DefaultValue =
                        (gvEvaluateMethod.Rows[i].FindControl("txtPercent") as TextBox).Text;
                    EvalMethodSyllabusDataSource.InsertParameters[3].DefaultValue =
                        (gvEvaluateMethod.Rows[i].FindControl("txtLO") as TextBox).Text;
                    EvalMethodSyllabusDataSource.Insert();
                }
            }
        }
        Response.Redirect("/Admin/ManageSyllabus/" + sID);
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        int syllabusID = Convert.ToInt32("" + ViewData["syllabusID"]);
        string content = txtChaptName.Text;
        string lo = txtLOs.Text;
        var db = new SyllabusDataContext();

        CourseContent c = new CourseContent();
        c.Status = 1;
        c.SyllabusID = syllabusID;
        c.IsGroupSkill = false;
        c.IsIndividualSkill = false;
        c.CourseLOID = lo;
        c.ChapterName = content;
        if (cbNewChapt.Checked)
        {
            //GetLastChaptResult chapt = db.GetLastChapt(syllabusID).Single();
            List<GetLastChaptResult> chapt = db.GetLastChapt(syllabusID).ToList();
            if (chapt.Count == 0)
            {
                c.OrderNode = "" + 1;
                c.NodeLevel = 0;
            }
            else
            {
                c.NodeLevel = 0;
                int t = Convert.ToInt32(chapt[0].OrderNode) + 1;
                c.OrderNode = "" + t;
            }
            db.CourseContents.InsertOnSubmit(c);
            db.SubmitChanges();

            int newID = c.ID;
            c.RootID = newID;
            c.ParentID = newID;
            db.SubmitChanges();   
        }
        else 
        {
            int parentID = Convert.ToInt32(drlContent.SelectedValue);
            CourseContent parentChapt = db.CourseContents.Single(p => p.ID == parentID);
            c.RootID = parentChapt.RootID;
            c.ParentID = parentID;
            c.NodeLevel = parentChapt.NodeLevel + 1;

            List<CourseContent> lst = (from p in db.CourseContents
                       where p.ParentID == parentID
                       select p).ToList();
            int t = lst.Count;
            c.OrderNode = parentChapt.OrderNode + "." + t;
            db.CourseContents.InsertOnSubmit(c);
            db.SubmitChanges();
        }
        Response.Redirect("/Admin/ManageSyllabus/" + syllabusID);
    }

    protected void dataListCourseSkill_EditCommand(object source, DataListCommandEventArgs e)
    {
        dataListCourseSkill.EditItemIndex = (int)e.Item.ItemIndex;
        dataListCourseSkill.DataBind();
    }

    protected void dataListCourseSkill_UpdateCommand(object source, DataListCommandEventArgs e)
    {
        var db = new SyllabusDataContext();
        int syllabusID = Convert.ToInt32("" + ViewData["syllabusID"]);
        CourseSkill c = (from p in db.CourseSkills
                         where p.SyllabusID == syllabusID && p.Status == 1
                         select p).Single();
        c.IsIndividualSkill = ((CheckBox)e.Item.FindControl("cbInSkill")).Checked;
        c.IsGroupSkill = ((CheckBox)e.Item.FindControl("cbGroupSkill")).Checked;
        if ((bool)c.IsIndividualSkill)
        {
            c.IndividualSkill = ((TextBox)e.Item.FindControl("txtInSkill")).Text;
        }
        if ((bool)c.IsGroupSkill)
        {
            c.GroupSkill = ((TextBox)e.Item.FindControl("txtGroupSkill")).Text;
        }
        db.SubmitChanges();

        dataListCourseSkill.EditItemIndex = -1;
        dataListCourseSkill.DataBind();
    }
</script>
    
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Manage Syllabus
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript" src="../../Scripts/jquery-1.3.2.js"></script>    
    <script language="javascript" type="text/javascript">
    var edit = false;
    var contentID;
    var value;    
    var valueLO;
    var update = false;
    var updateLO = false;
    var editSkill = false;
    var isInSkill = false;
    var isGroupSkill = false;
    var txtInSkill = "";
    var txtGroupSkill = "";
//        function ActiveTabChanged(sender, e) {
//            var CurrentTab = $get('<%=CurrentTab.ClientID%>');
//            //CurrentTab.innerHTML = sender.get_activeTab().get_headerText();
//            //var index = sender.get_activeTab().get_tabIndex();          
//        }

        $(function() {
            $("span").click(function() {
                
                if (!edit) {
                   // alert("click: " + edit);
                    edit = true;
                    var id = $(this).attr("id");
                    contentID = id.substring(1,id.length);                    
                    if (id.charAt(0) == 's') {
                        if (id.charAt(1) == 'x') { // edit chapter
                            contentID = id.substring(2,id.length);
                            $("#w" + contentID).removeAttr("disabled");
                            $("#e" + contentID).css("display", "none");
                            $("#r" + contentID).css("display", "inline");                            
                            $("#r" + contentID).val($("#e" + contentID).text());
                            isInSkill = $("#w" + contentID).attr('checked');
                            txtInSkill = $("#e" + contentID).text();
                            
                            $("#q" + contentID).removeAttr("disabled");
                            $("#p" + contentID).css("display", "none");
                            $("#y" + contentID).css("display", "inline");                            
                            $("#y" + contentID).val($("#p" + contentID).text());
                            isGroupSkill = $("#q" + contentID).attr('checked');
                            txtGroupSkill = $("#p" + contentID).text();
                            editSkill = true;
                        }
                        value = $("#" + id).text();
                        $("#" + id).css("display", "none");
                        $("#t" + contentID).css("display", "inline");
                        $("#i" + contentID).val(value);
                        $("#u" + contentID).css("display", "inline");
                        $("#d" + contentID).css("display", "inline");
                        update = true;
                    }
                    if (id.charAt(0) == 'm') {
                        valueLO = $("#" + id).text();
                        $("#" + id).css("display", "none");
                        $("#o" + contentID).css("display", "inline");
                        $("#l" + contentID).val(valueLO);
                        $("#ux" + contentID).css("display", "inline");
                        updateLO = true;
                    }                    
                }          
            }); 
            
            
            $("a").click(function() {
                var id = $(this).attr("id");
                
                //alert("click: " + edit);
                if (id.charAt(0) == 'u') {
                    if (update) {
                        var check = true; //true == update
                        var content = $("#i" + contentID).val();
                        if (content == value) { //cancel update
                            if (editSkill) {
                                var skill1 = $("#r" + contentID).val();
                                var skill2 = $("#y" + contentID).val();
                                var opt1 = $("#w" + contentID).attr('checked');
                                var opt2 = $("#q" + contentID).attr('checked');
                                if (opt1 == isInSkill && opt2 == isGroupSkill && skill1 == txtInSkill && skill2 == txtGroupSkill) {
                                    check = false;
                                    $("#w" + contentID).attr('disabled', 'disabled');
                                    $("#e" + contentID).css("display", "inline");
                                    $("#r" + contentID).css("display", "none");                                                               
                                    
                                    $("#q" + contentID).attr('disabled', 'disabled');
                                    $("#p" + contentID).css("display", "inline");
                                    $("#y" + contentID).css("display", "none"); 
                                    
                                    $("#sx" + contentID).css("display", "inline");
                                    $("#t" + contentID).css("display", "none");
                                    $("#sx" + contentID).val(value);
                                    $("#u" + contentID).css("display", "none"); 
                                    $("#d" + contentID).css("display", "none");                           
                                }                           
                            }
                            else {
                                $("#s" + contentID).css("display", "inline");
                                $("#t" + contentID).css("display", "none");
                                $("#s" + contentID).val(value);
                                $("#u" + contentID).css("display", "none"); 
                                $("#d" + contentID).css("display", "none");
                                check = false;
                            }
                                                                                 
                        }
                        if (check) { // update
                            if (editSkill) {
                                var skill1 = $("#r" + contentID).val();
                                var skill2 = $("#y" + contentID).val();
                                var opt1 = $("#w" + contentID).attr('checked');
                                var opt2 = $("#q" + contentID).attr('checked');
                                var url = "/Admin/UpdateCourseSkill";
                                $.post(url, {contentID: contentID, option1: opt1, iSkill: skill1, option2:opt2, gSkill:skill2}, function(data) {
                                
                                });

                            }
                            var url = "/Admin/UpdateContentName/" + contentID + "/" + content;
                            $.post(url, null, function(data) {
                                if (data == "1")
                                    location.reload();
                                else {
                                    $("#s" + contentID).css("display", "inline");
                                    $("#t" + contentID).css("display", "none");
                                    $("#s" + contentID).val(value);
                                    $("#u" + contentID).css("display", "none");
                                    $("#d" + contentID).css("display", "none"); 
                                }        
                            });
                        }
                        update = false;                       
                    }                   
                    if (updateLO) {
                        var content = $("#l" + contentID).val();
                        if (content == valueLO && editSkill==false) { //cancel update
                            $("#m" + contentID).css("display", "inline");
                            $("#o" + contentID).css("display", "none");
                            $("#m" + contentID).val(valueLO); 
                            $("#ux" + contentID).css("display", "none");                         
                        }
                        else {
                            var url = "/Admin/UpdateContentLO/" + contentID + "/" + content;
                            $.post(url, null, function(data) {
                                if (data == "1")
                                    location.reload();
                                else {
                                    $("#m" + contentID).css("display", "inline");
                                    $("#o" + contentID).css("display", "none");
                                    $("#m" + contentID).val(value);
                                    $("#ux" + contentID).css("display", "none");
                                }        
                            });
                        } 
                        updateLO = false;                   
                    }
                    edit = false; 
                }
                if (id.charAt(0) == 'd') {
                    var url = "/Admin/DeleteCourseContent/" + contentID;
                    $.post(url, null, function(data) {
                        location.reload();
                    });
                }
                                
            });
        });
            
    </script>
    <h2>Syllabus Management</h2>
    
    <asp:Label ID="lbSID" runat="server" Visible="False"></asp:Label>
    <asp:Label ID="lbLanguge" runat="server" Visible="False"></asp:Label>
    <asp:Label ID="scheduleID" runat="server" Visible="False"></asp:Label>
    
<%  int check = Int32.Parse("" + ViewData["scheduleID"]);
    if (check != -1)
    {
    %>         
    <br />
    <cc1:TabContainer ID="Tabs" runat="server" 
         ActiveTabIndex="0" Height="900px" Width="700px">
        <cc1:TabPanel runat="server" ID="TabPanel1" HeaderText="Course Content" >
            <HeaderTemplate>Course Content
            </HeaderTemplate>
            <ContentTemplate>
            <div id="courseContent">
            <br /><div class="tabHeader">Course Content</div><br />
                       
            <span style="font-size:smaller">(Click to content for editting)</span>
            <table width="537" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
            <tbody><tr style="color:White;background-color:#006699;font-weight:bold;">
                <th colspan="2" align="center" scope="col">Content</th>
                <th width="120" align="center" scope="col">Learning outcome</th>
                
            <%
            int pos = 0;
            int chapt = 0;
            int syllabusID = Convert.ToInt32(lbSID.Text);
            var sDB = new SyllabusDataContext();
            List<GetCourseContentResult> contentLst = sDB.GetCourseContent(syllabusID).ToList();
            GetCourseContentResult content;
            //foreach (GetCourseContentResult content in contentLst) { 
            for (int i = 0; i < contentLst.Count; i++)
            {               
                content = contentLst[i];
                switch (content.NodeLevel)
                {
                    case 0:
                        if (chapt != 0)
                        { %>
                    <tr>
                    <% if ((bool)contentLst[pos].IsIndividualSkill) { %>
                        <td width="140"><input id="w<%=contentLst[pos].ID%>" type="checkbox" checked="checked" disabled="disabled"/>Individual Skill</td>
                    <%} else { %>
                        <td width="140"><input id="w<%=contentLst[pos].ID%>" type="checkbox" disabled="disabled"/>Individual Skill</td>
                    <%} %>
                    
                    <td colspan="2">
                        <span id="e<%=contentLst[pos].ID%>"><%=contentLst[pos].IndividualSkill%></span>
                        <input style="display:none" type="text" id="r<%=contentLst[pos].ID%>" /></td>
                    </tr>  
                    
                    <tr>
                    <% if ((bool)contentLst[pos].IsGroupSkill) { %>
                        <td width="140"><input id="q<%=contentLst[pos].ID%>" type="checkbox" checked="checked" disabled="disabled"/>Group Skill</td>
                    <%} else { %>
                        <td width="140"><input id="q<%=contentLst[pos].ID%>" type="checkbox" disabled="disabled"/>Group Skill</td>
                    <%} %>
                                        
                    <td colspan="2">
                        <span id="p<%=contentLst[pos].ID%>"><%=contentLst[pos].GroupSkill%></span>
                        <input style="display:none" type="text" id="y<%=contentLst[pos].ID%>" /></td>
                    </tr> 
                   <% } chapt = 1;   
                        pos = i;
                        %>
                <tr>
                <td colspan="2" style="border-top: solid 1px #000000">    
                    <b>Chapter <%=content.OrderNode%>.&nbsp;
                    <span id="sx<%=content.ID%>"><%=content.ChapterName%></span></b>
                    <span id="t<%=content.ID%>" style="display:none">
                    <input type="text" id="i<%=content.ID%>" /></span>
                    <a style="display:none" id="u<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    <a style="display:none" id="d<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/delete.png" title="remove"/></a>
                    </td>
                <td align="center" style="border-top: solid 1px #000000">
                    <span id="m<%=content.ID%>"><%=content.CourseLOID%></span>
                    <span id="o<%=content.ID%>" style="display:none">
                    <input type="text" size="8" id="l<%=content.ID%>" /></span>
                    <a style="display:none" id="ux<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    </td>
                </tr>    
                <%	break;
                    case 1: %>
                <tr>
                <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
                    <%=content.OrderNode%>.&nbsp;
                    <span id="s<%=content.ID%>"><%=content.ChapterName%></span>
                    <span id="t<%=content.ID%>" style="display:none">
                    <input type="text" id="i<%=content.ID%>" /></span>
                    <a style="display:none" id="u<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    <a style="display:none" id="d<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/delete.png" title="remove"/></a>
                    </td>
                <td align="center">
                    <span id="m<%=content.ID%>"><%=content.CourseLOID%></span>
                    <span id="o<%=content.ID%>" style="display:none">
                    <input type="text" size="8" id="l<%=content.ID%>" /></span>
                    <a style="display:none" id="ux<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    </td></tr>
                <%  break;
                    case 2: %>
                <tr>
                <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <%=content.OrderNode%>.&nbsp;
                    <span id="s<%=content.ID%>"><%=content.ChapterName%></span>
                    <span id="t<%=content.ID%>" style="display:none">
                    <input type="text" id="i<%=content.ID%>" /></span>
                    <a style="display:none" id="u<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    <a style="display:none" id="d<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/delete.png" title="remove"/></a>
                    </td>
                <td align="center">
                    <span id="m<%=content.ID%>"><%=content.CourseLOID%></span>
                    <span id="o<%=content.ID%>" style="display:none">
                    <input type="text" size="8" id="l<%=content.ID%>" /></span>
                    <a style="display:none" id="ux<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    </td></tr>
                
                <%  break;
                    case 3: %>
                <tr>
                <td colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <%=content.OrderNode%>.&nbsp;
                    <span id="s<%=content.ID%>"><%=content.ChapterName%></span>
                    <span id="t<%=content.ID%>" style="display:none">
                    <input type="text" id="i<%=content.ID%>" /></span>
                    <a style="display:none" id="u<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    <a style="display:none" id="d<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/delete.png" title="remove"/></a>
                    </td>
                <td align="center">
                    <span id="m<%=content.ID%>"><%=content.CourseLOID%></span>
                    <span id="o<%=content.ID%>" style="display:none">
                    <input type="text" size="8" id="l<%=content.ID%>" /></span>
                    <a style="display:none" id="ux<%=content.ID%>" href="javascript://" ><img src="../../App_Themes/UserTheme/images/update.png" title="update"/></a>
                    </td></tr>
                <% break;
                }


            } %>
                    
                <% if (contentLst.Count > 0)
                   {
                     %>  <tr>
                    <% if ((bool)contentLst[pos].IsIndividualSkill) { %>
                        <td width="140"><input id="w<%=contentLst[pos].ID%>" type="checkbox" checked="checked" disabled="disabled"/>Individual Skill</td>
                    <%} else { %>
                        <td width="140"><input id="w<%=contentLst[pos].ID%>" type="checkbox" disabled="disabled"/>Individual Skill</td>
                    <%} %>
                    
                    <td colspan="2">
                        <span id="e<%=contentLst[pos].ID%>"><%=contentLst[pos].IndividualSkill%></span>
                        <input style="display:none" type="text" id="r<%=contentLst[pos].ID%>" /></td>
                    </tr>  
                    
                    <tr>
                    <% if ((bool)contentLst[pos].IsGroupSkill) { %>
                        <td width="140"><input id="q<%=contentLst[pos].ID%>" type="checkbox" checked="checked" disabled="disabled"/>Group Skill</td>
                    <%} else { %>
                        <td width="140"><input id="q<%=contentLst[pos].ID%>" type="checkbox" disabled="disabled"/>Group Skill</td>
                    <%} %>
                                        
                    <td colspan="2">
                        <span id="p<%=contentLst[pos].ID%>"><%=contentLst[pos].GroupSkill%></span>
                        <input style="display:none" type="text" id="y<%=contentLst[pos].ID%>" /></td>
                    </tr>
                    <%}
                    %>    
              
           </tbody>
           </table>
           </div>
            <br />
                <asp:DataList ID="dataListCourseSkill" runat="server" 
                    DataSourceID="CourseSkillDataSource" 
                    oneditcommand="dataListCourseSkill_EditCommand" 
                    onupdatecommand="dataListCourseSkill_UpdateCommand">
                    <EditItemTemplate>
                       <table width="537" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
                      <tr>
                        <td width="142">
                            <asp:CheckBox ID="cbInSkill" runat="server" 
                                Checked='<%# Bind("IsIndividualSkill") %>' Text="Individual Skill" /></td>
                        <td width="345">
                            <asp:TextBox ID="txtInSkill" runat="server" 
                                Text='<%# Bind("IndividualSkill") %>'></asp:TextBox>
                          </td>
                        <td width="50" rowspan="2" align="center" valign="center">
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                                CommandName="Update" Text="Update"></asp:LinkButton>
                            <br /><asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                          </td>
                      </tr>
                      <tr>
                        <td><asp:CheckBox ID="cbGroupSkill" runat="server" 
                                Checked='<%# Bind("IsGroupSkill") %>' Text="Group Skill" /></td>
                        <td>
                            <asp:TextBox ID="txtGroupSkill" runat="server" Text='<%# Bind("GroupSkill") %>'></asp:TextBox>
                          </td>
                        </tr>
                    </table> 
                    </EditItemTemplate>
                    <HeaderTemplate>
                        &nbsp;Summary Individual Skill & Group Skill in the Course
                    </HeaderTemplate>
                    <HeaderStyle BackColor="#006699" BorderStyle="Solid" BorderWidth="1px" 
                        Font-Bold="True" ForeColor="White" Height="10px" />
                    <ItemTemplate>
                     <table width="537" border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
                      <tr>
                        <td width="142">
                            <asp:CheckBox ID="cbInSkill" runat="server" 
                                Checked='<%# Bind("IsIndividualSkill") %>' Text="Individual Skill" 
                                Enabled="False" /></td>
                        <td width="345">
                            <asp:Label ID="lbInSkill" runat="server" 
                                Text='<%# Bind("IndividualSkill") %>'></asp:Label></td>
                        <td width="50" rowspan="2" align="center">
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                CommandName="Edit" Text="Edit"></asp:LinkButton>
                          </td>
                      </tr>
                      <tr>
                        <td><asp:CheckBox ID="cbGroupSkill" runat="server" 
                                Checked='<%# Bind("IsGroupSkill") %>' Text="Group Skill" Enabled="False" /></td>
                        <td><asp:Label ID="lbGroupSkill" runat="server" Text='<%# Bind("GroupSkill") %>'></asp:Label></td>
                        </tr>
                    </table>  
                    </ItemTemplate>
                </asp:DataList>
           <br />
                <asp:SqlDataSource ID="CourseSkillDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    SelectCommand="SELECT ID, SyllabusID, IsIndividualSkill, IsGroupSkill, IndividualSkill, GroupSkill, Status FROM CourseSkill WHERE (SyllabusID = @syllabusID) AND (Status = 1)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lbSID" Name="syllabusID" PropertyName="Text" />
                    </SelectParameters>
                </asp:SqlDataSource>
           
           <br />
           <asp:Panel ID="PnlShowAddContent" runat="server" style="cursor: pointer;">
            <div class="heading"><asp:ImageButton ID="ImageButton1" runat="server" AlternateText="expand" ImageUrl="~/App_Themes/UserTheme/images/expand.jpg" />
            <span style="color:Blue; font-size:13px;">Add New Content</span> </div></asp:Panel>
            
            <asp:Panel id="PnlAddContent" runat="server" style="overflow:hidden;" Height="0px">
            Content: 
                <asp:TextBox ID="txtChaptName" runat="server"></asp:TextBox><br />
            Learning outcome:
                <asp:TextBox ID="txtLOs" runat="server"></asp:TextBox><br />
            Belong to: 
                <asp:DropDownList ID="drlContent" runat="server" 
                    DataSourceID="CourseContDataSource" DataTextField="ChapterName" 
                    DataValueField="ID">
                </asp:DropDownList> or
                <asp:CheckBox ID="cbNewChapt" runat="server" Text="New chapter" />
                <br />
                <asp:Button ID="btnAdd" runat="server" Text="Add" onclick="btnAdd_Click" />                            
            
                <asp:SqlDataSource ID="CourseContDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    SelectCommand="SELECT ID, ChapterName FROM CourseContent WHERE (SyllabusID = @syllabusID) AND (Status = 1) ORDER BY RootID, OrderNode">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lbSID" Name="syllabusID" PropertyName="Text" />
                    </SelectParameters>
                </asp:SqlDataSource>
            
           </asp:Panel><cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server"
            TargetControlID="PnlAddContent"
            ExpandControlID="PnlShowAddContent"
            CollapseControlID="PnlShowAddContent" Collapsed="True"       
            ImageControlID="ImageButton1" Enabled="True" /> 
            </ContentTemplate>
            </cc1:TabPanel>
        
        <cc1:TabPanel runat="server" ID="Panel3" HeaderText="Evaluate Method" >
            <HeaderTemplate>Evaluate Method
            </HeaderTemplate>
            <ContentTemplate>
            <br /><div class="tabHeader">Evaluate Methods</div><br /><asp:GridView 
                    ID="gvEvaluateMethod" runat="server" AutoGenerateColumns="False" 
                    BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
                    CellPadding="3" DataKeyNames="ID" 
                    DataSourceID="AllEvalMethodSqlDataSource">
                <Columns>
                    <asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID" 
                        Visible="False">
                        <EditItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ID" SortExpression="MethodID">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MethodID") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbMethodID" runat="server" Text='<%# Bind("MethodID") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Method" SortExpression="Method">
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Method") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lbMethod" runat="server" Text='<%# Bind("Method") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:CheckBox ID="cbMethod" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Percent">
                        <ItemTemplate>
                            <asp:TextBox ID="txtPercent" runat="server" Width="50px"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Correspond LO">
                        <ItemTemplate>
                            <asp:TextBox ID="txtLO" runat="server"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="White" ForeColor="#000066" />
                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                <RowStyle ForeColor="#000066" />
                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                </asp:GridView>
                <asp:SqlDataSource ID="AllEvalMethodSqlDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    SelectCommand="SELECT EvaluateMethod.ID, EvaluateMethod.MethodID, EvaluateMethodLanguage.Method FROM EvaluateMethod INNER JOIN EvaluateMethodLanguage ON EvaluateMethod.ID = EvaluateMethodLanguage.EvaluateID INNER JOIN Language ON EvaluateMethodLanguage.LanguageID = Language.ID WHERE (Language.Name = @language)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lbLanguge" DefaultValue="eng" Name="language" 
                            PropertyName="Text" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="EvalMethodSyllabusDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    
                    
                    SelectCommand="SELECT EvalMethodID, Percentage, CorrespondLOs FROM EvalMethodSyllabus WHERE (SyllabusID = @syllabus)" 
                    DeleteCommand="DELETE FROM EvalMethodSyllabus WHERE (SyllabusID = @syllabusID) AND (EvalMethodID = @methodID)" 
                    InsertCommand="INSERT INTO EvalMethodSyllabus(SyllabusID, EvalMethodID, Percentage, CorrespondLOs, Status) VALUES (@syllabusID, @methodID, @percent , @LO, 1)" 
                    UpdateCommand="UPDATE EvalMethodSyllabus SET Percentage = @percent , CorrespondLOs = @LO WHERE (SyllabusID = @syllabusID) AND (EvalMethodID = @methodID)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lbSID" Name="syllabus" PropertyName="Text" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="syllabusID" />
                        <asp:Parameter Name="methodID" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="syllabusID" />
                        <asp:Parameter Name="methodID" />
                        <asp:Parameter Name="percent" />
                        <asp:Parameter Name="LO" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="percent" />
                        <asp:Parameter Name="LO" />
                        <asp:Parameter Name="syllabusID" />
                        <asp:Parameter Name="methodID" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:LinkButton ID="lnUpdateEvalMethod" runat="server" 
                    onclick="lnUpdateEvalMethod_Click">Update</asp:LinkButton>
                <br />
            
            <br /><b>Grade Formula</b> <asp:DetailsView ID="dvFormula" runat="server" Height="50px" Width="183px" 
                    AutoGenerateRows="False" CellPadding="4" DataSourceID="GradeFormulaDataSource" 
                    ForeColor="#333333" GridLines="None" 
                    oniteminserting="dvFormula_ItemInserting" 
                    onitemdeleting="dvFormula_ItemDeleting"><Fields><asp:TemplateField HeaderText="Formula" SortExpression="Formula"><EditItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>' Visible="False"></asp:Label><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Formula") %>'></asp:TextBox></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="txtFormula" runat="server" Text='<%# Bind("Formula") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>' Visible="False"></asp:Label><asp:Label ID="lbFormula" runat="server" Text='<%# Bind("Formula") %>'></asp:Label></ItemTemplate><ControlStyle Width="200px" /></asp:TemplateField><asp:CommandField ShowDeleteButton="True" ShowEditButton="True" 
                            ShowInsertButton="True" /></Fields><AlternatingRowStyle BackColor="White" ForeColor="#284775" /><CommandRowStyle BackColor="#E2DED6" Font-Bold="True" /><EditRowStyle BackColor="#999999" /><FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" /><FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /><RowStyle BackColor="#F7F6F3" ForeColor="#333333" /></asp:DetailsView><asp:SqlDataSource ID="GradeFormulaDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    
                    SelectCommand="SELECT TOP (1) Formula, ID FROM GradeFormula WHERE (SyllabusID = @SyllabusID) AND (Status = 1) ORDER BY ID DESC" 
                    DeleteCommand="UPDATE GradeFormula SET Status = 0 WHERE (ID = @ID)" 
                    UpdateCommand="UPDATE GradeFormula SET Formula = @Formula WHERE (ID = @ID)"><SelectParameters><asp:ControlParameter ControlID="lbSID" Name="SyllabusID" PropertyName="Text" /></SelectParameters><DeleteParameters><asp:Parameter Name="ID" /></DeleteParameters><UpdateParameters><asp:Parameter Name="Formula" /><asp:Parameter Name="ID" /></UpdateParameters></asp:SqlDataSource>
                    </ContentTemplate>
        </cc1:TabPanel>
                                    
        <cc1:TabPanel runat="server" ID="Panel1" HeaderText="Teaching Method">
            <HeaderTemplate>Teaching Method
            </HeaderTemplate>
            <ContentTemplate><br /><div class="tabHeader">Teaching Methods</div><br /><asp:GridView ID="gvTeachingMethod" runat="server" BackColor="White" BorderColor="#CCCCCC" 
                    BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                    AutoGenerateColumns="False" DataKeyNames="ID" 
                    DataSourceID="AllTeachMethodDataSource"><Columns><asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID" 
                            Visible="False"><EditItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="ID" SortExpression="MethodID"><EditItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MethodID") %>'></asp:TextBox></EditItemTemplate><ItemTemplate><asp:Label ID="lbMethodID" runat="server" Text='<%# Bind("MethodID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Method" SortExpression="Method"><EditItemTemplate><asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Method") %>'></asp:TextBox></EditItemTemplate><ItemTemplate><asp:Label ID="lbMethod" runat="server" Text='<%# Bind("Method") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField><ItemTemplate><asp:CheckBox ID="cbTeachMethod" runat="server" /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Description"><ItemTemplate><asp:TextBox ID="txtDescription" runat="server"></asp:TextBox></ItemTemplate></asp:TemplateField></Columns><FooterStyle BackColor="White" ForeColor="#000066" /><HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /><RowStyle ForeColor="#000066" /><SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /></asp:GridView><asp:SqlDataSource ID="AllTeachMethodDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    SelectCommand="SELECT TeachingMethod.ID, TeachingMethod.MethodID, TeachingMethodLanguage.Method FROM TeachingMethod INNER JOIN TeachingMethodLanguage ON TeachingMethod.ID = TeachingMethodLanguage.TeachingMethodID INNER JOIN Language ON TeachingMethodLanguage.LanguageID = Language.ID WHERE (Language.Name = @language)"><SelectParameters><asp:ControlParameter ControlID="lbLanguge" DefaultValue="eng" Name="language" 
                            PropertyName="Text" /></SelectParameters></asp:SqlDataSource><asp:SqlDataSource ID="TeachMethodSyllabusDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    
                    SelectCommand="SELECT TeachingMethodID, Description FROM TeachMethodSyllabus WHERE (SyllabusID = @syllabusID) AND (Status = 1)" 
                    
                    InsertCommand="INSERT INTO TeachMethodSyllabus(SyllabusID, TeachingMethodID, Description, Status) VALUES (@syllabusId, @methodID, @description, 1)" 
                    
                    
                    
                    DeleteCommand="DELETE FROM TeachMethodSyllabus WHERE (SyllabusID = @SyllabusID) AND (TeachingMethodID = @ID)" 
                    
                    UpdateCommand="UPDATE TeachMethodSyllabus SET Description = @description WHERE (SyllabusID = @syllabusID) AND (TeachingMethodID = @teachID)"><SelectParameters><asp:ControlParameter ControlID="lbSID" Name="syllabusID" PropertyName="Text" /></SelectParameters><DeleteParameters><asp:Parameter Name="SyllabusID" /><asp:Parameter Name="ID" /></DeleteParameters><InsertParameters><asp:Parameter Name="syllabusId" /><asp:Parameter Name="methodID" /><asp:Parameter Name="description" /></InsertParameters><UpdateParameters><asp:Parameter Name="description" /><asp:Parameter Name="syllabusID" /><asp:Parameter Name="teachID" /></UpdateParameters></asp:SqlDataSource><asp:LinkButton ID="lnkUpdate" runat="server" onclick="lnkUpdate_Click">Update</asp:LinkButton>
                
            </ContentTemplate>
        </cc1:TabPanel>
        
         <cc1:TabPanel runat="server" ID="tabSchedule" HeaderText="Course Schedule">
            <HeaderTemplate>Course Schedule
            </HeaderTemplate>
            <ContentTemplate><br /><div class="tabHeader">Course Schedule</div><br /><asp:DetailsView ID="dvSchedule" runat="server" Height="50px" Width="251px" 
                    AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="ScheduleDataSource" 
                    GridLines="None"><Fields><asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID" 
                            Visible="False"><EditItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("ID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Theory Time" SortExpression="TheoryTime"><EditItemTemplate><asp:TextBox ID="txtTheoryTime" runat="server" Text='<%# Bind("TheoryTime") %>' 
                                    Width="30px"></asp:TextBox>&#160;<asp:Label ID="Label6" runat="server" Text="hours"></asp:Label></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("TheoryTime") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("TheoryTime") %>'></asp:Label>&#160;<asp:Label ID="Label61" runat="server" Text="hours"></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Exercise Time" SortExpression="ExerciseTime"><EditItemTemplate><asp:TextBox ID="txtExTime" runat="server" Text='<%# Bind("ExerciseTime") %>' 
                                    Width="30px"></asp:TextBox>&#160;<asp:Label ID="Label62a" runat="server" Text="hours"></asp:Label></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ExerciseTime") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="Label3" runat="server" Text='<%# Bind("ExerciseTime") %>'></asp:Label>&#160;<asp:Label ID="Label62" runat="server" Text="hours"></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Extra Reading" SortExpression="ExtraReadingTime"><EditItemTemplate><asp:TextBox ID="txtExtraTime" runat="server" 
                                    Text='<%# Bind("ExtraReadingTime") %>' Width="30px"></asp:TextBox>&#160;<asp:Label ID="Label63a" runat="server" Text="hours"></asp:Label></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="TextBox3" runat="server" 
                                    Text='<%# Bind("ExtraReadingTime") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="Label4" runat="server" Text='<%# Bind("ExtraReadingTime") %>'></asp:Label>&#160;<asp:Label ID="Label63" runat="server" Text="hours"></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Lab Time" SortExpression="LabTime"><EditItemTemplate><asp:TextBox ID="txtLabtime" runat="server" Text='<%# Bind("LabTime") %>' 
                                    Width="30px"></asp:TextBox>&#160;<asp:Label ID="Label64a" runat="server" Text="hours"></asp:Label></EditItemTemplate><InsertItemTemplate><asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("LabTime") %>'></asp:TextBox></InsertItemTemplate><ItemTemplate><asp:Label ID="Label5" runat="server" Text='<%# Bind("LabTime") %>'></asp:Label>&#160;<asp:Label ID="Label64" runat="server" Text="hours"></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField><EditItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                                    CommandName="Update" Text="Update"></asp:LinkButton>&#160;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                    CommandName="Cancel" Text="Cancel"></asp:LinkButton></EditItemTemplate><ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                    CommandName="Edit" Text="Edit"></asp:LinkButton></ItemTemplate></asp:TemplateField></Fields></asp:DetailsView><asp:SqlDataSource ID="ScheduleDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    
                    SelectCommand="SELECT ID, TheoryTime, ExerciseTime, ExtraReadingTime, LabTime, Status FROM CourseSchedule WHERE (ID = @ID)" 
                    UpdateCommand="UPDATE CourseSchedule SET TheoryTime = @TheoryTime, ExerciseTime = @ExerciseTime, ExtraReadingTime = @ExtraReadingTime, LabTime = @LabTime WHERE (ID = @ID)"><SelectParameters><asp:ControlParameter ControlID="scheduleID" Name="ID" PropertyName="Text" /></SelectParameters><UpdateParameters><asp:Parameter Name="TheoryTime" /><asp:Parameter Name="ExerciseTime" /><asp:Parameter Name="ExtraReadingTime" /><asp:Parameter Name="LabTime" /><asp:Parameter Name="ID" /></UpdateParameters></asp:SqlDataSource><br /><asp:Panel ID="PnlShowPractice" runat="server" style="cursor: pointer;"><div class="heading"><asp:ImageButton ID="ImageButton3" runat="server" AlternateText="expand" ImageUrl="~/App_Themes/UserTheme/images/expand.jpg" /><span style="color:Blue; font-size:13px;">Practice Lecture</span> </div></asp:Panel><asp:Panel id="PnlPractice" runat="server" style="overflow:hidden;" Height="0px"><asp:GridView ID="gvPractice" runat="server" AutoGenerateColumns="False" CellPadding="3" 
                    DataKeyNames="ID" DataSourceID="PracticeDataSource" BackColor="White" 
                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
                onrowdatabound="gvPractice_RowDataBound" ShowFooter="True" 
                AllowPaging="True" PageSize="3"><Columns><asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID" 
                    Visible="False"><EditItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Eval("ID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="CourseScheduleID" 
                    SortExpression="CourseScheduleID" Visible="False"><EditItemTemplate><asp:Label ID="lbScheduleID" runat="server" 
                            Text='<%# Bind("CourseScheduleID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="lbScheduleID" runat="server" 
                            Text='<%# Bind("CourseScheduleID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Practice Lecture"><EditItemTemplate><asp:TextBox ID="txtTopic" runat="server" Text='<%# Bind("Name") %>' 
                            Width="80px"></asp:TextBox><br /><asp:CheckBox ID="cbox1" runat="server" Checked='<%# Bind("LectureLab") %>' 
                            Text="Lecture in Lab" /><br /><asp:CheckBox ID="cbox2" runat="server" Checked='<%# Bind("LabPractice") %>' 
                            Text="Lab Practice" /><br /><asp:CheckBox ID="cbox3" runat="server" Checked='<%# Bind("HomePractice") %>' 
                            Text="Home Practice" /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtTopic" runat="server" Width="80px"></asp:TextBox><br /><asp:CheckBox ID="cbox1" runat="server" Checked='<%# Bind("LectureLab") %>' 
                            Text="Lecture in Lab" /><br /><asp:CheckBox ID="cbox2" runat="server" Checked='<%# Bind("LabPractice") %>' 
                            Text="Lab Practice" /><br /><asp:CheckBox ID="cbox3" runat="server" Checked='<%# Bind("HomePractice") %>' 
                            Text="Home Practice" /></FooterTemplate><ItemTemplate><asp:Label ID="lbNumber" runat="server" Text="Label"></asp:Label><asp:Label ID="lbTopic" runat="server" Text='<%# Bind("Name") %>'></asp:Label><br /><asp:CheckBox ID="CheckBox1" runat="server" 
                            Text="Lecture in Lab" Checked='<%# Bind("LectureLab") %>' /><br /><asp:CheckBox ID="CheckBox2" runat="server" 
                            Checked='<%# Bind("LabPractice") %>' Text="Lab Practice" /><br /><asp:CheckBox ID="CheckBox3" runat="server" 
                            Checked='<%# Bind("HomePractice") %>' Text="Home Practice" /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Chapter" SortExpression="Chapter"><EditItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Chapter") %>' 
                            Width="30px"></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtChapter" runat="server" Text='<%# Bind("Chapter") %>' 
                            Width="30px"></asp:TextBox></FooterTemplate><ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("Chapter") %>'></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /></asp:TemplateField><asp:TemplateField HeaderText="WorkingHour" SortExpression="WorkingHour"><EditItemTemplate><asp:TextBox ID="txtHour" runat="server" Text='<%# Bind("WorkingHour") %>' 
                            Width="30px"></asp:TextBox><asp:Label ID="Label3a" runat="server" Text="hours"></asp:Label></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtHour" runat="server" Text='<%# Bind("WorkingHour") %>' 
                            Width="30px"></asp:TextBox><asp:Label ID="Label3a" runat="server" Text="hours"></asp:Label></FooterTemplate><ItemTemplate><asp:Label ID="Label3" runat="server" Text='<%# Bind("WorkingHour") %>'></asp:Label><asp:Label ID="Label3a" runat="server" Text="hours"></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /></asp:TemplateField><asp:TemplateField HeaderText="Resources" SortExpression="Resources"><EditItemTemplate><asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Resources") %>' 
                            Width="100px"></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtRes" runat="server" Text='<%# Bind("Resources") %>' 
                            Width="80px"></asp:TextBox></FooterTemplate><ItemTemplate><asp:Label ID="Label4" runat="server" Text='<%# Bind("Resources") %>' 
                            Width="80px"></asp:Label></ItemTemplate><HeaderStyle HorizontalAlign="Center" /></asp:TemplateField><asp:TemplateField HeaderText="Duration" SortExpression="Duration"><EditItemTemplate><asp:Label ID="Label5b" runat="server" Text="Week"></asp:Label><asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Duration") %>' 
                            Width="30px"></asp:TextBox></EditItemTemplate><FooterTemplate><asp:Label ID="Label5b" runat="server" Text="Week"></asp:Label><asp:TextBox ID="txtWeek" runat="server" Text='<%# Bind("Duration") %>' 
                            Width="30px"></asp:TextBox></FooterTemplate><ItemTemplate><asp:Label ID="Label5a" runat="server" Text="Week"></asp:Label><asp:Label ID="Label5" runat="server" Text='<%# Bind("Duration") %>'></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /></asp:TemplateField><asp:TemplateField><EditItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update"></asp:LinkButton>&#160;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel"></asp:LinkButton></EditItemTemplate><FooterTemplate><asp:LinkButton ID="btnInsertPractice" runat="server" 
                            onclick="btnInsertPractice_Click">Insert</asp:LinkButton></FooterTemplate><ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit"></asp:LinkButton><asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete"></asp:LinkButton></ItemTemplate></asp:TemplateField>
                </Columns><FooterStyle BackColor="White" ForeColor="#000066" /><HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /><RowStyle ForeColor="#000066" /><SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                </asp:GridView><asp:SqlDataSource ID="PracticeDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                    
                SelectCommand="SELECT ID, CourseScheduleID, Name, Chapter, WorkingHour, Resources, Duration, LectureLab, LabPractice, HomePractice, Status FROM Practice WHERE (CourseScheduleID = @CourseScheduleID) AND (Status = 1)" 
                
                UpdateCommand="UPDATE Practice SET Name = @Name, Chapter = @Chapter, WorkingHour = @WorkingHour, Resources = @Resources, Duration = @Duration, LectureLab = @LectureLab, LabPractice = @LabPractice, HomePractice = @HomePractice WHERE (ID = @ID)" 
                DeleteCommand="DELETE FROM Practice WHERE (ID = @ID)"><SelectParameters><asp:ControlParameter ControlID="scheduleID" Name="CourseScheduleID" 
                            PropertyName="Text" /></SelectParameters><DeleteParameters><asp:Parameter Name="ID" /></DeleteParameters><UpdateParameters><asp:Parameter Name="Name" /><asp:Parameter Name="Chapter" /><asp:Parameter Name="WorkingHour" /><asp:Parameter Name="Resources" /><asp:Parameter Name="Duration" /><asp:Parameter Name="LectureLab" /><asp:Parameter Name="LabPractice" /><asp:Parameter Name="HomePractice" /><asp:Parameter Name="ID" /></UpdateParameters></asp:SqlDataSource></asp:Panel><cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender3" runat="server"
            TargetControlID="PnlPractice"
            ExpandControlID="PnlShowPractice"
            CollapseControlID="PnlShowPractice" Collapsed="True"       
            ImageControlID="ImageButton3" Enabled="True" /><br /><asp:Panel ID="PnlShowProject" runat="server" style="cursor: pointer;"><div class="heading"><asp:ImageButton ID="ImageButton4" runat="server" AlternateText="expand" ImageUrl="~/App_Themes/UserTheme/images/expand.jpg" /><span style="color:Blue; font-size:13px;">Course Project</span> </div></asp:Panel><asp:Panel id="PnlProject" runat="server" style="overflow:hidden;" Height="0px"><asp:GridView ID="gvProject" runat="server" AutoGenerateColumns="False" CellPadding="3" 
                    DataKeyNames="ID" DataSourceID="ProjectDataSource" BackColor="White" 
                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
                onrowdatabound="gvProject_RowDataBound" ShowFooter="True" 
                AllowPaging="True" PageSize="3"><Columns><asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID" 
                    Visible="False"><EditItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Eval("ID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="CourseScheduleID" 
                    SortExpression="CourseScheduleID" Visible="False"><EditItemTemplate><asp:Label ID="lbScheduleID" runat="server" 
                            Text='<%# Bind("CourseScheduleID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="lbScheduleID" runat="server" 
                            Text='<%# Bind("CourseScheduleID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Course Project"><EditItemTemplate><asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>' 
                            Width="80px"></asp:TextBox><br /><asp:CheckBox ID="cbox1" runat="server" Checked='<%# Bind("Presentation") %>' 
                            Text="Presentation" /><br /><asp:CheckBox ID="cbox2" runat="server" Checked='<%# Bind("RealProject") %>' 
                            Text="Real Project" /></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtName" runat="server" Width="80px"></asp:TextBox><br /><asp:CheckBox ID="cbox1" runat="server" Checked='<%# Bind("LectureLab") %>' 
                            Text="Presentation" /><br /><asp:CheckBox ID="cbox2" runat="server" Checked='<%# Bind("LabPractice") %>' 
                            Text="Real Project" /></FooterTemplate><ItemTemplate><asp:Label ID="lbNumber" runat="server" Text="Label"></asp:Label><asp:Label ID="lbName" runat="server" Text='<%# Bind("Name") %>'></asp:Label><br /><asp:CheckBox ID="CheckBox1" runat="server" 
                            Text="Presentation" Checked='<%# Bind("Presentation") %>' /><br /><asp:CheckBox ID="CheckBox2" runat="server" 
                            Checked='<%# Bind("RealProject") %>' Text="Real Project" /><br /></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="Chapter" SortExpression="Chapter"><EditItemTemplate><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Chapter") %>' 
                            Width="30px"></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtChapter" runat="server" Text='<%# Bind("Chapter") %>' 
                            Width="30px"></asp:TextBox></FooterTemplate><ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("Chapter") %>'></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /></asp:TemplateField><asp:TemplateField HeaderText="WorkingHour" SortExpression="WorkingHour"><EditItemTemplate><asp:TextBox ID="txtHour" runat="server" Text='<%# Bind("WorkingHour") %>' 
                            Width="30px"></asp:TextBox><asp:Label ID="Label3a" runat="server" Text="hours"></asp:Label></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtHour" runat="server" Text='<%# Bind("WorkingHour") %>' 
                            Width="30px"></asp:TextBox><asp:Label ID="Label3a" runat="server" Text="hours"></asp:Label></FooterTemplate><ItemTemplate><asp:Label ID="Label3" runat="server" Text='<%# Bind("WorkingHour") %>'></asp:Label><asp:Label ID="Label3a" runat="server" Text="hours"></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /></asp:TemplateField><asp:TemplateField HeaderText="Resources" SortExpression="Resources"><EditItemTemplate><asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Resources") %>' 
                            Width="100px"></asp:TextBox></EditItemTemplate><FooterTemplate><asp:TextBox ID="txtRes" runat="server" Text='<%# Bind("Resources") %>' 
                            Width="80px"></asp:TextBox></FooterTemplate><ItemTemplate><asp:Label ID="Label4" runat="server" Text='<%# Bind("Resources") %>' 
                            Width="80px"></asp:Label></ItemTemplate><HeaderStyle HorizontalAlign="Center" /></asp:TemplateField><asp:TemplateField HeaderText="Duration" SortExpression="Duration"><EditItemTemplate><asp:Label ID="Label5b" runat="server" Text="Week"></asp:Label><asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Duration") %>' 
                            Width="30px"></asp:TextBox></EditItemTemplate><FooterTemplate><asp:Label ID="Label5b" runat="server" Text="Week"></asp:Label><asp:TextBox ID="txtWeek" runat="server" Text='<%# Bind("Duration") %>' 
                            Width="30px"></asp:TextBox></FooterTemplate><ItemTemplate><asp:Label ID="Label5a" runat="server" Text="Week"></asp:Label><asp:Label ID="Label5" runat="server" Text='<%# Bind("Duration") %>'></asp:Label></ItemTemplate><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /></asp:TemplateField><asp:TemplateField><EditItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update"></asp:LinkButton>&#160;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel"></asp:LinkButton></EditItemTemplate><FooterTemplate><asp:LinkButton ID="btnInsertProject" runat="server" 
                            onclick="btnInsertProject_Click">Insert</asp:LinkButton></FooterTemplate><ItemTemplate><asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit"></asp:LinkButton><asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                            CommandName="Delete" Text="Delete"></asp:LinkButton></ItemTemplate></asp:TemplateField>
                </Columns><FooterStyle BackColor="White" ForeColor="#000066" /><HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /><RowStyle ForeColor="#000066" /><SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                </asp:GridView><asp:SqlDataSource ID="ProjectDataSource" runat="server" 
                ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                
                SelectCommand="SELECT ID, CourseScheduleID, Name, Chapter, WorkingHour, Resources, Duration, Presentation, RealProject, Status FROM Project WHERE (CourseScheduleID = @CourseScheduleID) AND (Status = 1)" 
                DeleteCommand="DELETE FROM Project WHERE (ID = @ID)" 
                UpdateCommand="UPDATE Project SET Name = @Name, Chapter = @Chapter, WorkingHour = @WorkingHour, Resources = @Resources, Duration = @Duration, Presentation = @Presentation, RealProject = @RealProject WHERE (ID = @ID)"><SelectParameters><asp:ControlParameter ControlID="scheduleID" Name="CourseScheduleID" 
                        PropertyName="Text" /></SelectParameters><DeleteParameters><asp:Parameter Name="ID" /></DeleteParameters><UpdateParameters><asp:Parameter Name="Name" /><asp:Parameter Name="Chapter" /><asp:Parameter Name="WorkingHour" /><asp:Parameter Name="Resources" /><asp:Parameter Name="Duration" /><asp:Parameter Name="Presentation" /><asp:Parameter Name="RealProject" /><asp:Parameter Name="ID" /></UpdateParameters></asp:SqlDataSource></asp:Panel><cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender4" runat="server"
            TargetControlID="PnlProject"
            ExpandControlID="PnlShowProject"
            CollapseControlID="PnlShowProject" Collapsed="True"       
            ImageControlID="ImageButton4" Enabled="True" /><br /><asp:Panel ID="PnlShowLecture" runat="server" style="cursor: pointer;"><div class="heading"><asp:ImageButton ID="ImageButton5" runat="server" AlternateText="expand" ImageUrl="~/App_Themes/UserTheme/images/expand.jpg" /><span style="color:Blue; font-size:13px;">Theory Lecture</span> </div></asp:Panel><asp:Panel id="PnlLecture" runat="server" style="overflow:hidden;" Height="0px"><asp:GridView ID="gvLecture" runat="server" AutoGenerateColumns="False" 
                DataSourceID="LectureDataSource" AllowPaging="True" PageSize="3" 
                onrowdatabound="gvLecture_RowDataBound" ShowFooter="True" 
                onrowupdating="gvLecture_RowUpdating" BackColor="White" 
                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" 
                onrowdeleting="gvLecture_RowDeleting"><Columns><asp:TemplateField><EditItemTemplate><table border="1" cellspacing="0" 
                                style="width:100%; height:92px; border-color:#CCCCCC"><tr><td><asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>' 
                                            Width="90px"></asp:TextBox></td></tr><tr><td><asp:CheckBox ID="cbox1" runat="server" Checked='<%# Bind("Topic") %>' 
                                            Text="Summary Topic" TextAlign="Left" /></td></tr><tr><td><asp:CheckBox ID="cbox2" runat="server" Checked='<%# Bind("Reference") %>' 
                                            Text="Reference" TextAlign="Left" /></td></tr></table></EditItemTemplate><FooterTemplate><table border="1" cellspacing="0" 
                                style="width:100%; height:92px; border-color:#CCCCCC"><tr><td><asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>' 
                                            Width="90px"></asp:TextBox></td></tr><tr><td><asp:CheckBox ID="cbox1" runat="server" Checked='<%# Bind("Topic") %>' 
                                            Text="Summary Topic" TextAlign="Left" /></td></tr><tr><td><asp:CheckBox ID="cbox2" runat="server" Checked='<%# Bind("Reference") %>' 
                                            Text="Reference" TextAlign="Left" /></td></tr></table></FooterTemplate><HeaderTemplate>Lecture Topics</HeaderTemplate><ItemTemplate><table style="width:100%; height:72px; border-color:#CCCCCC" cellspacing="0" border="1"><tr><td><asp:Label ID="lbNumber" runat="server" Text="Label"></asp:Label><asp:Label ID="lbTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label></td></tr><tr><td><asp:CheckBox ID="checkbox1" runat="server" Checked='<%# Bind("Topic") %>' 
                                            Text="Summary Topic" TextAlign="Left" /></td></tr><tr><td><asp:CheckBox ID="CheckBox5" runat="server" Checked='<%# Bind("Reference") %>' 
                                            Text="Reference" TextAlign="Left" /></td></tr></table></ItemTemplate></asp:TemplateField><asp:TemplateField><EditItemTemplate><table border="1" cellspacing="0" 
                            style="width:100%; height:92px; border-color:#CCCCCC"><tr><td align="center" width="58"><asp:TextBox ID="txtChapter" runat="server" Text='<%# Bind("Chapter") %>' 
                                        Width="54px"></asp:TextBox></td><td align="center" width="126"><asp:DropDownList ID="dlTeachMethod" runat="server" 
                                        DataSourceID="TeachingMethodDataSource0" DataTextField="MethodID" 
                                        DataValueField="ID" SelectedValue='<%# Bind("TeachingMethodID") %>' 
                                        Width="100px"></asp:DropDownList></td><td align="center" width="126"><asp:DropDownList ID="dlEvalMethod" runat="server" 
                                        DataSourceID="EvalMethodDataSource0" DataTextField="MethodID" 
                                        DataValueField="ID" SelectedValue='<%# Bind("EvalMethodID") %>' Width="100px"></asp:DropDownList></td><td align="center"><asp:TextBox ID="txtDuration" runat="server" Text='<%# Bind("Duration") %>' 
                                        Width="54px"></asp:TextBox></td></tr><tr><td colspan="4"><asp:TextBox ID="txtDes" runat="server" Text='<%# Bind("TopicDescription") %>' 
                                        Width="250px"></asp:TextBox></td></tr><tr><td colspan="4"><asp:TextBox ID="txtRef" runat="server" Text='<%# Bind("ReferenceData") %>' 
                                        Width="250px"></asp:TextBox></td></tr></table></EditItemTemplate><FooterTemplate><table border="1" cellspacing="0" 
                                style="width:100%; height:92px; border-color:#CCCCCC"><tr><td align="center" width="58"><asp:TextBox ID="txtChapter" runat="server" Text='<%# Bind("Chapter") %>' 
                                            Width="54px"></asp:TextBox></td><td align="center" width="126"><asp:DropDownList ID="dlTeachMethod" runat="server" 
                                            DataSourceID="TeachingMethodDataSource0" DataTextField="MethodID" 
                                            DataValueField="ID" Width="100px"></asp:DropDownList></td><td align="center" width="126"><asp:DropDownList ID="dlEvalMethod" runat="server" 
                                            DataSourceID="EvalMethodDataSource0" DataTextField="MethodID" 
                                            DataValueField="ID" SelectedValue='<%# Bind("EvalMethodCode") %>' Width="100px"></asp:DropDownList></td><td align="center"><asp:TextBox ID="txtDuration" runat="server" Text='<%# Bind("Duration") %>' 
                                            Width="54px"></asp:TextBox></td></tr><tr><td colspan="4"><asp:TextBox ID="txtDes" runat="server" Text='<%# Bind("TopicDescription") %>' 
                                            Width="250px"></asp:TextBox></td></tr><tr><td colspan="4"><asp:TextBox ID="txtRef" runat="server" Text='<%# Bind("ReferenceData") %>' 
                                            Width="250px"></asp:TextBox>&#160;<asp:LinkButton ID="btnInsertLecture" runat="server" 
                                            onclick="btnInsertLecture_Click">Insert</asp:LinkButton></td></tr></table></FooterTemplate><HeaderTemplate><table border="1" cellspacing="0" style="width:100%; border-color:#CCCCCC"><tr><td width="55">Chapter</td><td width="126">Teaching Method</td><td width="126">Evaluate Method</td><td width="55">Duration</td></tr></table></HeaderTemplate><ItemTemplate><table border="1" cellspacing="0" 
                            style="width:100%; height:72px; border-color:#CCCCCC"><tr><td align="center" width="58"><asp:Label ID="lbChapter" runat="server" Text='<%# Bind("Chapter") %>' 
                                        Width="54px"></asp:Label></td><td align="center" width="126"><asp:Label ID="lbTeachMethod" runat="server" 
                                        Text='<%# Bind("TeachMethodCode") %>' Width="100px"></asp:Label></td><td align="center" width="126"><asp:Label ID="lbEvalMethod" runat="server" 
                                        Text='<%# Bind("EvalMethodCode") %>' Width="100px"></asp:Label></td><td align="center"><asp:Label ID="lbDuration" runat="server" Text='<%# Bind("Duration") %>' 
                                        Width="54px"></asp:Label></td></tr><tr><td colspan="4">&#160;<asp:Label ID="lbDes" runat="server" Text='<%# Bind("TopicDescription") %>'></asp:Label></td></tr><tr><td colspan="4">&#160;<asp:Label ID="lbRef" runat="server" Text='<%# Bind("ReferenceData") %>'></asp:Label></td></tr></table></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID" 
                        Visible="False"><EditItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Eval("ID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="lbID" runat="server" Text='<%# Bind("ID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:TemplateField HeaderText="CourseScheduleID" 
                    SortExpression="CourseScheduleID" Visible="False"><EditItemTemplate><asp:Label ID="lbScheduleID" runat="server" 
                            Text='<%# Bind("CourseScheduleID") %>'></asp:Label></EditItemTemplate><ItemTemplate><asp:Label ID="Label2" runat="server" 
                            Text='<%# Bind("CourseScheduleID") %>'></asp:Label></ItemTemplate></asp:TemplateField><asp:CommandField ShowDeleteButton="True" /><asp:CommandField ShowEditButton="True" /></Columns><FooterStyle BackColor="White" ForeColor="#000066" /><HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /><PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /><RowStyle ForeColor="#000066" /><SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /></asp:GridView><asp:SqlDataSource ID="LectureDataSource" runat="server" 
                ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                
                
                
                SelectCommand="SELECT TheoryLecture.ID, TheoryLecture.CourseScheduleID, TheoryLecture.Title, TheoryLecture.TopicDescription, TheoryLecture.ReferenceData, TheoryLecture.Chapter, TheoryLecture.TeachingMethodID, TheoryLecture.EvalMethodID, TheoryLecture.Duration, TeachingMethod.MethodID AS TeachMethodCode, EvaluateMethod.MethodID AS EvalMethodCode, TheoryLecture.Topic, TheoryLecture.Reference FROM TheoryLecture INNER JOIN TeachMethodSyllabus ON TheoryLecture.TeachingMethodID = TeachMethodSyllabus.ID INNER JOIN TeachingMethod ON TeachMethodSyllabus.TeachingMethodID = TeachingMethod.ID INNER JOIN EvalMethodSyllabus ON TheoryLecture.EvalMethodID = EvalMethodSyllabus.ID INNER JOIN EvaluateMethod ON EvalMethodSyllabus.EvalMethodID = EvaluateMethod.ID WHERE (TheoryLecture.CourseScheduleID = @CourseScheduleID) AND (TheoryLecture.Status = 1)"><SelectParameters><asp:ControlParameter ControlID="scheduleID" Name="CourseScheduleID" 
                        PropertyName="Text" /></SelectParameters></asp:SqlDataSource><asp:SqlDataSource ID="TeachingMethodDataSource0" runat="server" 
                ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                SelectCommand="SELECT TeachMethodSyllabus.ID, TeachingMethod.MethodID FROM TeachingMethod INNER JOIN TeachMethodSyllabus ON TeachingMethod.ID = TeachMethodSyllabus.TeachingMethodID WHERE (TeachMethodSyllabus.SyllabusID = @SID)"><SelectParameters><asp:ControlParameter ControlID="lbSID" Name="SID" PropertyName="Text" /></SelectParameters></asp:SqlDataSource><asp:SqlDataSource ID="EvalMethodDataSource0" runat="server" 
                ConnectionString="<%$ ConnectionStrings:CDIO1ConnectionString %>" 
                SelectCommand="SELECT EvalMethodSyllabus.ID, EvaluateMethod.MethodID FROM EvalMethodSyllabus INNER JOIN EvaluateMethod ON EvalMethodSyllabus.EvalMethodID = EvaluateMethod.ID WHERE (EvalMethodSyllabus.SyllabusID = @SID)"><SelectParameters><asp:ControlParameter ControlID="lbSID" Name="SID" PropertyName="Text" /></SelectParameters></asp:SqlDataSource></asp:Panel><cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender5" runat="server"
            TargetControlID="PnlLecture"
            ExpandControlID="PnlShowLecture"
            CollapseControlID="PnlShowLecture" Collapsed="True"       
            ImageControlID="ImageButton5" Enabled="True" /><br />
            
            <asp:Panel ID="PnlShowSummary" runat="server" style="cursor: pointer;">
            <div class="heading"><asp:ImageButton ID="ImageButton6" runat="server" AlternateText="expand" ImageUrl="~/App_Themes/UserTheme/images/expand.jpg" />
            <span style="color:Blue; font-size:13px;">Summary Course Schedule</span> </div></asp:Panel>
            
            <asp:Panel id="PnlSummary" runat="server" style="overflow:hidden;" Height="0px">
           <table cellspacing="0" cellpadding="3" border="1" bordercolor="#CCCCCC">
			<tbody>
            <tr style="color:White;background-color:#006699;font-weight:bold;">
			    <th scope="col">Week</th>
			    <th colspan="3" scope="col" align="center">1-3</th>
                <th colspan="3" scope="col" align="center">4-6</th>
                
            	<th colspan="3" scope="col" align="center">7-9</th>
			    <th colspan="3" scope="col" align="center">10-12</th>
                <th colspan="3" scope="col" align="center">13-15</th>
			</tr>
            <tr>
			    <td><b>Theory Lecture</b></td>
			    <td colspan="15">&#160;</td>
              </tr>
              <% 
                  int sID = Convert.ToInt32("" + ViewData["scheduleID"]);
                  var scheduleDB = new CourseScheduleDataContext();
                  var lecture = scheduleDB.GetLectureInfo(sID);
                  foreach (GetLectureInfoResult l in lecture) { %>
                      
                  <tr>
			        <td><%=l.Title%></td>
			        
			        <% string duration = l.Duration;
                      string[] weeks = duration.Split('-');
                      int a1, a2;
                      a1 = Convert.ToInt32(weeks[0]);
                      if (weeks.Length == 2)
                      {
                          a2 = Convert.ToInt32(weeks[1]);
                      }
                      else {
                          a2 = a1;
                      }
                      for (int i = 1; i < 16; i++)
                      {
                          if (a1 <= i && i <= a2) { %>
                              <td style="background-color:#000000;">&#160;&#160;&#160;</td>
                          <% }
                          else { %>
                              <td>&#160;&#160;&#160;</td>
                          <% }
                      }
                           
                    %>			      
                  </tr>
                  <%}
                  %>
                
              <tr>
			    <td><b>Practice Lecture</b></td>
			    <td colspan="15">&#160;</td>
              </tr>
              <%                   
                  var practice = scheduleDB.GetPracticeInfo(sID);
                  foreach (GetPracticeInfoResult prac in practice) { %>
                      
                  <tr>
			        <td><%=prac.Name%></td>
			        
			        <% string duration = prac.Duration;
                      string[] weeks = duration.Split('-');
                      int a1, a2;
                      a1 = Convert.ToInt32(weeks[0]);
                      if (weeks.Length == 2)
                      {                        
                          a2 = Convert.ToInt32(weeks[1]);
                      } else {
                          a2 = a1;
                      }
                      for (int i = 1; i < 16; i++)
                      {
                          if (a1 <= i && i <= a2) { %>
                              <td style="background-color:#000000;">&#160;&#160;&#160;</td>
                          <% }
                          else { %>
                              <td>&#160;&#160;&#160;</td>
                          <% }
                      }
                           
                    %>			      
                  </tr>
                  <%}
                  %>
                  
            <tr>
			    <td><b>Course Project</b></td>
			    <td colspan="15">&#160;</td>
              </tr>
              <%                   
                  var project = scheduleDB.GetProjectInfo(sID);
                  foreach (GetProjectInfoResult proj in project)
                  { %>
                      
                  <tr>
			        <td><%=proj.Name%></td>
			        
			        <% string duration = proj.Duration;
                      string[] weeks = duration.Split('-');
                      int a1, a2;
                      a1 = Convert.ToInt32(weeks[0]);
                      if (weeks.Length == 2)
                      {                        
                          a2 = Convert.ToInt32(weeks[1]);
                      } else {
                          a2 = a1;
                      }
                      for (int i = 1; i < 16; i++)
                      {
                          if (a1 <= i && i <= a2) { %>
                              <td style="background-color:Black;">&#160;&#160;&#160;</td>
                          <% }
                          else { %>
                              <td>&#160;&#160;&#160;</td>
                          <% }
                      }
                           
                    %>			      
                  </tr>
                  <%}
                  %>          
            
		</tbody></table>
             
             
             </asp:Panel><cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender6" runat="server"
            TargetControlID="PnlSummary"
            ExpandControlID="PnlShowSummary"
            CollapseControlID="PnlShowSummary" Collapsed="True"       
            ImageControlID="ImageButton6" Enabled="True" /> 
        
            
        </ContentTemplate>
        </cc1:TabPanel>
                 
        </cc1:TabContainer>
        
        <asp:Label runat="server" ID="CurrentTab" /><br />        
  <% }%>   
</asp:Content>
